WITH Ada.Text_IO;
WITH Ada.Strings.Unbounded;
WITH Ada.Strings.Unbounded.Hash;
WITH Ada.Strings.Unbounded.Text_IO;
WITH Ada.Strings.Maps;
WITH Ada.Containers.Hashed_Maps;
WITH Ada.Exceptions;

USE Ada.Strings.Unbounded;


PACKAGE Console_Interface.Menus IS

  TYPE Menu  IS PRIVATE;

  TYPE Action IS ACCESS PROCEDURE;

  PROCEDURE Set_Name (A_Menu : IN OUT Menu ; Name : IN String);
  PROCEDURE Add_Item (A_Menu : IN OUT Menu ; Index : IN String; Label : IN String; A_Proc : ACCESS PROCEDURE);
  PROCEDURE Add_Exit_Item (A_Menu : IN OUT Menu ; Index : IN String; Label : IN String);
  PROCEDURE Execute (A_Menu : IN Menu);

PRIVATE

  FUNCTION Equivalent_Key (Left, Right : Unbounded_String) RETURN Boolean;

  PACKAGE Item_Hash IS NEW Ada.Containers.Hashed_Maps (
						       Element_Type    => Unbounded_String,
						       Key_Type        => Unbounded_String,
						       Hash            => Hash,
						       Equivalent_Keys => Equivalent_Key);

  PACKAGE Action_Hash IS NEW Ada.Containers.Hashed_Maps (
						       Element_Type    => Action,
						       Key_Type        => Unbounded_String,
						       Hash            => Hash,
						       Equivalent_Keys => Equivalent_Key);



 TYPE Menu_Status IS (Init_Status,Run_Status, Exit_Status);


  TYPE Menu IS RECORD
    Name  : Unbounded_String;
    Items : Item_Hash.Map;
    Actions : Action_Hash.Map;
    Status  : Menu_Status := Init_Status;
    Close_Key : Unbounded_String;
  END RECORD;

END Console_Interface.Menus;
